{% extends 'base.html' %}
{% block title %}
    <title>资源详情页</title>
    <link rel="shortcut icon" href="/static/favicon.ico">
{% endblock %}
{% block customcss %}
    <style>
    .resource_desc_main{
        margin-bottom: 15px;
    border-radius: 2px;
    background-color: #fff;
    box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);
    }
    .content .layui-col-md6{margin-bottom: 5px;}
    td{overflow: hidden;}
    .api-desc li{line-height: 34px;
    border-bottom: 1px dashed #ddd;}
    .table-head{    background-color: #f2f2f2;}
    .table-head tr{    height: 42px;}
    tr{line-height: 40px;}
    .span-custom{font-size: 17px;padding: 5px}
    .chc-dl dl dd{float: left}
    .chc-dl dl dd:nth-child(2){margin-left: 20px}
    /* 会话框 */
    .container {
    height: 550px;
    width: 50%;
    display: flex;
    margin: 0 auto;
    position: fixed;
    top: 129px;
    display: none;
    left:96px;
    }
    .chatbox {
    /* margin: auto; */
    height: 77%;
    width: 100%;
    transform: translateY(-10%);
    box-shadow: 0 0 0 1px gray;
    display: flex;
    overflow: hidden;
    }
    .chatleft {
    background-color: #ffffff;
    width: 50%;
    left: 0;
    height: 100%;
    }
    .chatleft .top {
    /* height: 15%; */
    color: grey;
    background-color: #F7F9F9;
    display: flex;
    align-items: center;
    }
    .searchbtn {
    height: 31px;
    width: 36px;
    border-radius: 18px;
    background-color: #1f94bf;
    color: #ECF0F1;
    margin-left: 10px;
    }
    .searchbtn:hover {
    cursor: pointer;
    }
    /* .chatleft .center {
    overflow-y: scroll;
    height: 90%;
    } */
    .chatleft .center {
    overflow-y: scroll;
    height: 100%;
    }
    .chatleft .center ul{
    padding-left: 10px;
    }
    .chatleft .center li{
    margin: 10px;
    position: relative;
    }
    .chatleft .center .selected{
        background: #edf5f8;
    }
    .chatright {
    background-color: #ffffff;
    /* width: 75%; */
    height: 100%;
    }
    .chatright .top {
    height: 15%;
    display: flex;
    align-items: center;
    padding-left: 30px;
    }
    .chatright .center {
    background-color: #edf5f8;
    height: 65%;
    overflow-y: scroll;
    }
    .chatright .center ul {
    padding: 10px;
    }
    .chatright .center li {
    margin: 10px;
    width: 100%;
    }
    .chatright .center p{
    display: inline-block;
    }
    .msgcard {
    margin: 0 10px 0 10px;
    background-color: white;
    border-radius: 10px;
    padding: 10px;
    max-width: 60%;
    }
    .msgleft {
    float: left;
    }
    .msgright {
    /* float: right; */
    }
    .chatright .footer {
    height: 25%;
    background-color: #FBFCFC;
    text-align: right;
    }
    .sendbtn {
    height: 40px;
    width: 80px;
    border-radius: 10px;
    background-color: #58D68D;
    color: white;
    font-weight: bold;
    position: absolute;
    right: 6px;
    bottom: 6px;
    /* margin:10px 20px 0 0; */
    }
    .contone{
        display: none;
    }
    .show{
        display: block;
    }
    .weidumes{
        position: absolute;
        right: 0;
        bottom: 0;
        width: 25px;
        height: 15px;
        text-align: center;
        border-radius: 15px;
        background: #b8bac0;
        font-size: 10px;
        color: #fff;
    }
    </style>

{% endblock %}
{% block content %}
  <div class="layui-row layui-col-space30">
        <div class="layui-col-md12 resource_desc_main">
            <h1> {{ result.resource_name }}</h1>
            <h5 style="color: #999;line-height: 24px;">{{ result.resource_desc }}</h5>
            <br>
            <div class="content">
                    <div class="layui-row">
                        <div class="layui-col-md6">资源分类：{{ result.resource_cate }}</div>
                        <div class="layui-col-md6">资源状态：<span class="layui-badge layui-bg-green" style="padding: 5px 6px;">{{ result.resource_status }}</span></div>
                    </div>
                    <div class="layui-row" style="margin-top: 20px;">
                        <div class="layui-col-md6">创建时间：{{ result.addtimes}}</div>
                        <div class="layui-col-md6 chc-dl" >
                            <dl>
                                <dd userid="{{ result.userid }}">创建用户：{{ result.username}}</dd>
                                <dd class="chater" style="margin-top: -15px;"><svg t="1534296615117" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2334" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><defs><style type="text/css"></style></defs><path d="M558.545455 558.545455v151.272727a34.909091 34.909091 0 0 1-69.818182 0V558.545455h-151.272728a34.909091 34.909091 0 0 1 0-69.818182H488.727273v-151.272728a34.909091 34.909091 0 0 1 69.818182 0V488.727273h151.272727a34.909091 34.909091 0 0 1 0 69.818182H558.545455z m-46.545455 442.181818c-72.564364 0-142.661818-15.453091-208.546909-45.986909L129.349818 991.418182a58.228364 58.228364 0 0 1-55.831273-18.688 58.274909 58.274909 0 0 1-10.914909-57.856l44.544-124.788364C52.200727 710.912 23.272727 619.194182 23.272727 523.636364 23.272727 260.561455 242.525091 46.545455 512 46.545455s488.727273 214.016 488.727273 477.090909S781.474909 1000.727273 512 1000.727273z m-199.540364-119.202909l10.821819 5.329454A423.726545 423.726545 0 0 0 512 930.909091c230.981818 0 418.909091-182.714182 418.909091-407.272727C930.909091 299.077818 742.981818 116.363636 512 116.363636S93.090909 299.077818 93.090909 523.636364c0 86.551273 27.997091 169.518545 80.989091 239.918545l11.310545 15.010909-50.059636 140.241455 177.128727-37.282909z" fill="#1AAD16" p-id="2335"></path></svg>
                                    <p>发起聊天</p>
                                </dd>
                            </dl>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md6">修改时间：{{ result.updatetime  }}</div>
                        <div class="layui-col-md6">

                            {% if apply_for_status != ""%}
                                        {% if apply_for_status == 0 %}
                                            <span class="layui-badge layui-bg-gray span-custom">待审核</span>
                                        {% elif apply_for_status == 1 %}
                                            <span class="layui-badge layui-bg-blue span-custom" value="{{ token }}" id="apply_token">审核通过</span>
                                        {% elif apply_for_status == 2 %}
                                            <span class="layui-badge span-custom" >审核被拒绝</span>拒绝原因：{{ refuse_message }}
                                            <button class="layui-btn layui-btn-sm" id="apply_for">重新申请</button>
                                        {% endif %}
                                {% else %}
                                    {% if openStatus == 0 %}
                                        <button class="layui-btn layui-btn-sm" id="apply_for">申请</button>
                                    {% endif %}
                            {% endif %}

                        </div>
                    </div>
            </div>

            <br>
            <div class="content">
                <h3 style="font-weight: bold;    padding-bottom: 7px;">详情介绍：</h3>
                <p style="color: #758697;">{{ result.resource_content }}</p>
            </div>
        </div>
        <div class="layui-col-md12 resource_desc_main">

            <div>
                <label style="border-left: 3px solid #00968A;padding-left: 7px; ">资源信息</label>
                <div class="layui-tab">
                  <ul class="layui-tab-title">
                    <li class="layui-this"> 资源内容</li>
                    <li>资源样例</li>

                    <li>api详情</li>
                    <li>下载文件</li>
                  </ul>
                  <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <table class="layui-table">
                          <colgroup>
                            <col width="150">
                            <col width="200">
                            <col>
                          </colgroup>
                          <thead>
                            <tr>
                              <th>字段名</th>
                              <th>字段类型</th>
                              <th>字段描述</th>
                            </tr>
                          </thead>
                          <tbody>
                          {% for i in columnsdesc %}
                            <tr>
                              <td>{{ i.columns}}</td>
                              <td>{{ i.columntype }}</td>
                              <td>{{ i.desc }}</td>
                            </tr>
                            {% endfor %}
                          </tbody>
                        </table>
                    </div>
                    <div class="layui-tab-item">
                          <table class="layui-table" style="table-layout:fixed;">
                            <thead>
                              <tr>
                                {% for column in cloumnslist %}
                                    <th>{{ column }}</th>
                                {% endfor %}
                              </tr>
                            </thead>
                            <tbody>

                            {% for v in tabledata_10_last %}
                                <tr>
                                {% for n in v %}

                                            <td>{{ n }}</td>

                                    {% endfor %}
                                </tr>
                              {% endfor %}

                            </tbody>
                          </table>
                    </div>
                    <div class="layui-tab-item">
                        <div class="layui-collapse">
                          <div class="layui-colla-item">
                            <h2 class="layui-colla-title">api标示</h2>
                            <div class="layui-colla-content layui-show">
                                <ul class="api-desc">
                                    <li>api地址：{{ request.get_host }}/resource/api/{{ resource_id }}/</li>
                                    <li> 请求方法：GET</li>
                                    {% if openStatus == 0 %}
                                        <li> 请求示例： {{ request.get_host }}/resource/api/{{ resource_id }}/?username=您的用户名&token=您申请的TOKEN<button class="layui-btn layui-btn-normal layui-btn-radius layui-btn-xs" id="get_token_btn"> 点此获取TOKEN</button></li>
                                        {% elif openStatus == 1%}
                                        <li> 请求示例： {{ request.get_host }}/resource/api/{{ resource_id }}/?username=您的用户名&appkey=您的appkey<button class="layui-btn layui-btn-normal layui-btn-radius layui-btn-xs" id="get_appkey_btn"> 点此查看APPKEY</button></li>
                                    {% endif %}
                                </ul>
                            </div>
                          </div>
                            {% if openStatus == 0 %}
                          <div class="layui-colla-item">
                            <h2 class="layui-colla-title">api参数</h2>
                            <div class="layui-colla-content layui-show">
                                <table  lay-even="" lay-skin="nob">
                                  <colgroup>
                                    <col width="150">
                                    <col width="150">
                                    <col width="200">
                                    <col width="200">
                                    <col width="200">
                                  </colgroup>
                                  <thead class="table-head">
                                    <tr>
                                      <th>名称</th>
                                      <th>类型</th>
                                      <th>必填</th>
                                      <th>示例值</th>
                                      <th>描述</th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    <tr>
                                      <td>username</td>
                                      <td>string</td>
                                      <td>是</td>
                                      <td>admin</td>
                                      <td>当前用户的用户名</td>
                                    </tr>
                                    <tr>
                                      <td>token</td>
                                      <td>string</td>
                                      <td>是</td>
                                      <td>2d6cd089-f760-40d6-9193-d00ce895b1c6</td>
                                      <td>token认证</td>
                                    </tr>
                                    <tr>
                                      <td>page</td>
                                      <td>int</td>
                                      <td>是</td>
                                      <td>1</td>
                                      <td>分页，页码。每页1000条</td>
                                    </tr>
                                  </tbody>
                                </table>
                            </div>
                          </div>
                                {% elif openStatus == 1 %}
                          <div class="layui-colla-item">
                            <h2 class="layui-colla-title">api参数</h2>
                            <div class="layui-colla-content layui-show">
                                <table  lay-even="" lay-skin="nob">
                                  <colgroup>
                                    <col width="150">
                                    <col width="150">
                                    <col width="200">
                                    <col width="200">
                                    <col width="200">
                                  </colgroup>
                                  <thead class="table-head">
                                    <tr>
                                      <th>名称</th>
                                      <th>类型</th>
                                      <th>必填</th>
                                      <th>示例值</th>
                                      <th>描述</th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    <tr>
                                      <td>username</td>
                                      <td>string</td>
                                      <td>是</td>
                                      <td>admin</td>
                                      <td>当前用户的用户名</td>
                                    </tr>
                                    <tr>
                                      <td>page</td>
                                      <td>int</td>
                                      <td>是</td>
                                      <td>1</td>
                                      <td>分页，页码。每页1000条</td>
                                    </tr>
                                  </tbody>
                                </table>
                            </div>
                          </div>
                            {% endif %}
                          <div class="layui-colla-item">
                            <h2 class="layui-colla-title">api返回值</h2>
                            <div class="layui-colla-content layui-show">
                                <table  lay-even="" lay-skin="nob">
                                  <colgroup>
                                    <col width="150">
                                    <col width="150">
                                    <col width="200">
                                    <col width="300">
                                    <col>
                                  </colgroup>
                                  <thead class="table-head">
                                    <tr>
                                      <th>名称</th>
                                      <th>类型</th>
                                      <th>示例值</th>
                                      <th>描述</th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    <tr>
                                      <td>code</td>
                                      <td>int</td>
                                      <td>0</td>
                                      <td>0是请求成功，其它数字是失败，对应msg</td>
                                    </tr>
                                    <tr>
                                      <td>msg</td>
                                      <td>string</td>
                                      <td>参数错误</td>
                                      <td>如果请求失败，则是失败描述</td>
                                    </tr>

                                  </tbody>
                                </table>
                            </div>
                          </div>
                          <div class="layui-colla-item">
                            <h2 class="layui-colla-title">返回值示例</h2>
                            <div class="layui-colla-content layui-show">
                                  <pre class="layui-code" lay-title="JavaScript" lay-skin="notepad">//正确返回样例
{{ example_data }}
                                  </pre>
                            </div>
                          </div>
                        </div>
                    </div>
                    <div class="layui-tab-item">

                        {% if apply_for_status %}
                                        {% if apply_for_status == 0 %}
                                            <button class="layui-btn " id="apply_for" style="color: #fff;background-color: #c2c2c2;">待审核中...</button>
                                        {% elif apply_for_status == 1 %}
                                            <form action="/resource/api/{{ resource_id }}/download/" method="get">
                                                <button class="layui-btn" id="downloadfile" type="submit">下载文件</button>
                                            </form>
                                        {% elif apply_for_status == 2 %}
                                            <button class="layui-btn layui-btn-danger" id="apply_for">授权未通过...</button>
                                        {% endif %}
                            {% else %}
                                {% if openStatus == 0 %}
                                    <span class="layui-btn span-custom">点击上方申请按钮，并审核通过才能下载</span>
                                    {%  elif openStatus == 1 %}
                                    <form action="/resource/api/{{ resource_id }}/download/" method="get">
                                        <button class="layui-btn" id="downloadfile" type="submit">下载文件</button>
                                    </form>

                                {% endif %}
                        {% endif %}
                    </div>
                  </div>
                </div>
            </div>
        </div>
  </div>
  <!-- 会话窗口 -->
  <div class="container">
      <div class="chatbox">
          <div class="chatleft">
              <div class="top">
                  <!-- <input type="text" placeholder="search" style="width: 70%; height: 36px; margin-left: 25px;">
                  <button class="searchbtn"></style><i class="layui-icon layui-icon-search"></i></button> -->
              </div>
              <div class="center mans">
                  <!-- 成员列表 -->
                  <ul class="menslist">
                      <li>
                          <!-- <img style="border-radius: 20px; vertical-align: middle;" src="/static/images/chatheader1.png">
                          <span style="margin-left: 10px;">{{ result.username}}</span> -->
                      </li>
                  </ul>
              </div>
          </div>
          <div style="width:100%;">
              <div class="chatright talklist">
                  <!-- 会话名称 -->
                  <div class="top">
                      <img style="border-radius: 20px; vertical-align: middle;" src="/static/images/chatheader1.png">
                      <span style="margin-left: 20px;"></span>
                      <i class="layui-icon layui-icon-close" style="font-size: 1.4em; position: absolute; right: 20px; color: gray;"></i>
                  </div>
                  <!-- 会话内容 -->
                  <div class="center listcont">
                      <ul style="overflow:hidden;">
                          <!-- <li class="msgleft">
                              <img style="border-radius: 20px; vertical-align: top;" src="/static/images/chatheader1.png">
                              <p class="msgcard">2some messages</p>
                          </li> -->
                      </ul>
                  </div>
                  <div class="footer">
                      <textarea class="textareas" maxlength="800" rows="5" cols="40" style="width: 100%; resize: none; border: none; " placeholder="请在此输入要发送的内容..."></textarea>
                      <button class="sendbtn">发送</button>
                  </div>
              </div>
          </div>
      </div>
  </div>
{% endblock %}

{% block customjs %}
    <script type="text/javascript" src="/static/ztree/js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="/static/jquery/jquery.cookie.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.min.js"></script>
    <script type="text/javascript" src="/static/js/set_csrf_async.js"></script>
    <script>
    layui.use(['rate','element','layer'], function(){
      var element = layui.element,rate = layui.rate, layer = layui.layer;;
     //显示文字
      rate.render({
        elem: '#test2'
        ,value: 2 //初始值
        ,text: true //开启文本
      });


      $("#apply_for").on("click",function () {
          var userid="{{ userid }}";
          if (userid!="None" && userid!=undefined){
            $.ajax({
                url:"/user/resource/",
                type:"post",
                data:{"user_id":userid,"resource_id":{{ resource_id }},"resource_user_id":{{resource_user_id}}},
                success:function (data) {
                    if(data.code==0){
                        layer.msg("申请成功！等待申请结果吧！",{time:2000,end:function () {
                            window.location.reload()
                        }});

                    }
                }
            });
          }else{
              window.location.href="/user/login/";
          }


});
      $("#get_token_btn").on("click",function () {
          var apply_for_status="{{ apply_for_status }}";
          if(apply_for_status==1){
              var content=$("#apply_token").attr("value");
          }else {
              var content="你还未申请成功"
          }
            layer.open({
              title: '请复制你的token'
              ,content: content
            });

        })
    });
$("#get_appkey_btn").on("click",function () {
    $.ajax({
            url:"/resource/user/appkey/",
            type:"get",
            success:function (data) {
                if(data.code==0){
                layer.open({
                  title: '请复制你的token'
                  ,content: '<span class="layui-badge">请妥善保管你的appkey,以防他人调用</span> <br>'+data.data
                });

                }
            }
    })
})
    </script>
    <script>
    // 会话弹框
    $(document).ready(function () {
        // 拖拽谈话窗
        var mydrag={
            mousePoint: {x:0,y:0}, //初始化坐标
            drag: function(){
              var that=this; //保存当前对象即(mydrag)，如果不保存，在mousedown()里访问不了mydrag这个对象
              var targetid=$(".top");
              targetid.mousedown(function(event){
                    var e=event;
                    var offsetLeft=targetid.offset().left; //当前div的左偏移距离
                    var offsetTop=targetid.offset().top;  //当前div的顶部偏移距离
                    that.mousePoint.x=e.clientX-offsetLeft;//计算鼠标点击时离它自己div的横向距离
                    that.mousePoint.y=e.clientY-offsetTop;  //计算鼠标点击时离它自己div的纵向距离
                    $(document).bind('mousemove',move);
                    e.stopPropagation();
              });
              function move(event){
                  var e =event;
                  var Left=e.clientX-that.mousePoint.x; //移动后，重新计算左偏移和顶部偏移距离
                  var Top=e.clientY-that.mousePoint.y;
                  $(".container").css({'top':Top,'left':Left,'margin':0});
                  $(document).bind('mouseup',end);
                  e.stopPropagation();
              };
              function end(event){
                  var e = event;
                     $(document).unbind('mousemove', move);
                        $(document).unbind('mouseup',end);
                  e.stopPropagation();
              };
            }
        };
        mydrag.drag();
        var fromUserid = $.cookie('ui');
        $(".chater").click(function(){
            $(".container").toggle();
            $(".listcont").scrollTop(3000);
        });
        $(".layui-icon-close").click(function(){
            $(".container").toggle();
        });
        //建立socket连接
        var socket = io.connect("http://192.168.3.191:5000");
        socket.emit('chat_send', {
            fromUserid : fromUserid,
            flag : "init",
            message : ""
        });
        //点击发送消息
        socket.on('connect', function () {
          var form = $('.sendbtn').on('click' ,function (e) {
              e.preventDefault();
              if($(this).siblings().val().length <= 0) {layer.msg('消息不能为空');return false};
              var message = $(this).siblings().val();
              var toUserid = $('.selected').attr("id");//对方id
              socket.emit('chat_send', {
                  fromUserid : fromUserid,
                  message : message,
                  toUserid : toUserid
              },function(data){
                    if(data){
                        $('.textareas').val("");
                        $(".listcont ul").append("<li" + " class='msgleft'>" + "<img style='border-radius:20px;vertical-align:top;float:right;'src="
                         + "'/static/images/chatheader1.png'/>" + "<p class='msgcard'" + "style='float:right;'" + ">" + message + "</p>" + "</li>");
                    }else{
                        layer.msg('服务器繁忙，请稍后')
                    }
                    $(".listcont").scrollTop(3000);
              });
          });
      });
      // 点击会话人更换不同会话窗口
      $("body").on("click",".menslist li",function(){
          var i = $(this).index();//下标
          $(this).addClass('selected').siblings().removeClass('selected');
          var names = $(this).children('span').html();
          $('.talklist').children(".top").children("span").text('' + names + '');
          socket.emit('chat_send', {
              fromUserid : fromUserid,
              flag : "onetoone",
              toUserid : $(this).attr("id"),
              message : ""
          });
          socket.emit('chat_send', {
              fromUserid : fromUserid,
              flag : "read",
              toUserid : $(this).attr("id"),
          });
      });
      //初次加载数据以及切换数据
      socket.on('chat_recv_'+ fromUserid, function (data,ack) {
          console.log(data)
          var htmls = "";
          if(data.friends.length > 0){
              var html = "";
              var some = "";
              for (var variable in data.friends) {
                  var undermessages = data.friends[variable].unreadMessage == 0 ? "" : data.friends[variable].unreadMessage;
                  var weidumes = data.friends[variable].unreadMessage == 0 ? "" : "weidumes";
                  html += "<li id=" + data.friends[variable].userid + ">" + "<img style= 'border-radius: 20px; vertical-align: middle;'"
                  + "src='/static/images/chatheader1.png'" + ">" + "<span style='margin-left: 10px;'" + ">" + data.friends[variable].username
                  + "</span>" + "<span class=" + weidumes + ">"+ undermessages +"</span>" + "</li>";

                  if(data.friends[variable].message.length > 0 && data.friends[variable].message[1] == "he"){
                      some="" //在左边
                  }else {
                      some="float:right;"//在右边
                  };
                  if(data.flag == "init"){
                      htmls += "<li id=" + data.friends[variable].userid + " class='msgleft contone'>" + "<img style='border-radius: 20px; vertical-align: top;" + some + "'" + "src='/static/images/chatheader1.png'>"
                      + "<p class='msgcard'" + "style=" + some + ">" + data.friends[variable].message[0] + "</p>" + "</li>";
                  }
              };
              $(".menslist").html(html);
          };
          if(data.flag == "onetoone" && data.data.streaming.msg != undefined){
              var msgobj = (data.data.streaming.msg).reverse();
              for (var i in msgobj) {
                  if(msgobj[i][1] == "he"){
                      some="" //在左边
                  }else {
                      some="float:right;"//在右边
                  };
                  htmls += "<li" + " class='msgleft'>" + "<img style='border-radius: 20px; vertical-align: top;" + some + "'" + "src='/static/images/chatheader1.png'>"
                  + "<p class='msgcard'" + "style=" + some + ">" + msgobj[i][0] + "</p>" + "</li>";
              }
          };
          $(".listcont ul").html(htmls);

          //判断当前好友列表中是否存在指定对话人，如果没有，则添加指定对话人
          var result = true;
          $(".menslist").find("li").each(function(i){
              if($(this).attr("id") == {{ result.userid }}) {
                  result = true;
                  return false;
              }else{
                  result = false;
                  return
              }
          });
          if(!result){
              $(".menslist").eq(0).prepend("<li id=" + {{ result.userid }} + ">" + "<img style= 'border-radius: 20px; vertical-align: middle;'"
              + "src='/static/images/chatheader1.png'" + ">" + "<span style='margin-left: 10px;'" + ">{{ result.username}}"
              + "</span>" + "</li>");
              $(".listcont ul").html("");
          };

          if(data.flag == "init"){
              $(".menslist").find("li").each(function(i){
                  if($(this).attr("id") == {{ result.userid }}){
                      $(this).addClass("selected");
                  }
              });
              $(".listcont ul").find("li").each(function(i){
                  if($(this).attr("id") == {{ result.userid }}){
                      $(this).addClass("show");
                  }
              });
          };
          if(data.flag == "onetoone"){
              $(".menslist").find("li").each(function(i){
                  if($(this).attr("id") == data.data.streaming.fromUserid) {
                      $(this).addClass("selected");
                  };
              });
          };
          var names = $(".selected span").html();
          $('.talklist').children(".top").children("span").text('' + names + '');
          $(".listcont").scrollTop(3000);
      });
    });
    </script>
{% endblock %}
